package com.cloudsigns.factorymanager2.produce.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.IProductOrderReceiveView;
import com.cloudsigns.factorymanager2.produce.model.IProductOrderReceiveModel;
import com.cloudsigns.factorymanager2.produce.model.ProductOrderReceiveModel;

public class ProductOrderReceivePresenter {
    private IProductOrderReceiveView view;
    private IProductOrderReceiveModel model;
    private Handler mHandler = new Handler();

    public ProductOrderReceivePresenter(IProductOrderReceiveView iView) {
        this.view = iView;
        this.model = new ProductOrderReceiveModel();
    }

    public void productOrderReceive() {
        model.receiveOrbackProductOrder(view.getOrderId(), view.getStatus(), new ProductOrderReceiveModel.OnReceiveOrBackProductOrderListener() {
            @Override
            public void Successed() {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.receiveOrBackOrderSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.receiveOrBackOrderFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });
    }
}
